Hi everyone, I have some question about attributes. What is the difference between module attribute and object attribute? Importantly, how can I check the module attribute is empty or not? Thanks in advance Jonny Jonny Tim - Fri Nov 02 08:59:24 EDT 2018 |
Re: Check if module attribute is empty Hi Jonny, Module attributes contain information about the whole module as such. E.g. the name of the module, the description of the module, the date when the module was last modified, its prefix etc. are all module specific. An Object attribute contains information about a specific object, e.g. its Object Text, Heading, Level, custom attributes, the date when the object was last modified. As you see there are attributes that are only interesting for a module, those that are only interesting for an object and those that are interesting for both (e.g. date of creation, date of modification).
Whether an attribute is empty or not depends on the type of the attribute. Some example code partly taken from the reference manual:
AttrDef ad
Module m = current
for ad in m do {
if (ad.object) {
print "the attribute " (ad.name) " is defined on object level\n"
}
if (ad.module) {
print "the attribute " (ad.name) " is defined on module level\n"
}
}
string modDescription = m."Description"""
if (null modDescription) {
print "the module attribute called Description of the current module is empty"
} else {
print "the description of the module is " modDescription "\n"
}
Date modCreated = m."Created On"
if (null modCreated) {
print "this does not make sense, a module is created at some time in the past, cannot be empty\n"
}
|